﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ElectronicCommerce.Framework.Configuration;
using ElectronicCommerce.Framework.Payment.Configuration;
using ElectronicCommerce.Framework.Payment.Contract.DataContract.Common;
using ElectronicCommerce.Framework.Payment.Contract.ServiceContract;

namespace ElectronicCommerce.Framework.Payment.Service
{
    public class PaymentMethodService : IPaymentMethodService
    {
        /// <summary>
        /// 获取所有支付方式 
        /// </summary>
        /// <returns></returns>
        public List<PaymentMethod> GetPaymentMethods()
        {
            List<PaymentMethod> paymentMethods = new List<PaymentMethod>();

            PaymentModeCollection paymentModes = ConfigManager.GetConfig<PaymentConfig>().PaymentModes;
            if (paymentMethods != null)
            {
                foreach (PaymentMode paymentMode in paymentModes)
                {
                    paymentMethods.Add(new PaymentMethod()
                    {
                        Code = paymentMode.Code,
                        Name = paymentMode.Name,
                        Description = paymentMode.Description,
                        PayRate = paymentMode.PayRate,
                        IsOnlinePay = paymentMode.IsOnlinePay,
                        IsActive = paymentMode.IsActive
                    });
                }
            }

            return paymentMethods;
        }
    }
}
